
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title><?php if (is_numeric($id)) {
            echo '编辑需求';
        } else { ?>新增需求<?php }   if($_GET['type']=='see'){ $type="readonly='readonly'";} ?></title>
    <link href="../admin/adminstyle/1/adminstyle.css" rel="stylesheet" type="text/css">
    <script src="../admin/ecmseditor/cropimg/js/jquery-1.10.2.js"></script>
    <script src="../admin/ecmseditor/cropimg/js/jquery-ui.js"></script>
    <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
    <script>
        function selectalls(doselect, formvar) {
            var bool = doselect == 1 ? true : false;
            var selectform = document.getElementById(formvar);
            for (var i = 0; i < selectform.length; i++) {
                selectform.all[i].selected = bool;
            }
        }
    </script>
</head>

<body>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
    <tr>
        <td><p>位置：<a href="#">内部需求管理</a> &gt; <a href="#"><?php if (is_numeric($id)) {
                        echo '编辑需求';
                    } else { ?>新增需求<?php } ?></a></p>
    </tr>
</table>
<form name="form1" method="post" action="" id="requestfom">

    <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
        <tr class="header">
            <td height="25" colspan="2"><?php if (is_numeric($id)) {
                    echo '编辑需求';
                } else { ?>新增需求<?php } ?>
                <input name="id" type="hidden" id="id" value="<?=$info['id']?>">
        </tr>
        <tr bgcolor="#FFFFFF">
            <td width="22%" height="25">项目名称：</td>
            <td width="78%" height="25"><input name="info[project]" type="text" id="project"value="<?=$info['project']?>" size="32" required="required"  <?= $type ?>>*
            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td width="22%" height="25">功能模块：</td>
            <td width="78%" height="25"><input name="info[functional_module]" type="text" id="functional_module" value="<?=$info['functional_module']?>" required="required"   <?= $type ?>">  *

            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td width="22%" height="25">需求部门：</td>
            <td width="78%" height="25"><input name="info[department]" type="text" id="department" required="required" value="<?=$info['department']?>"   <?= $type ?>>  *

            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td width="22%" height="25">申请个人：</td>
            <td width="78%" height="25"><input name="info[applier_name]" type="text" id="applier_name" required="required"  value="<?=$info['applier_name']?>"  <?= $type ?>>  *

            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td width="22%" height="25">提出时间：</td>
            <td width="78%" height="25"><input name="info[start_time]" type="text" id="start_time"  required="required" value="<?=$info['start_time']?>"  value="<?=$info['start_time']?>"  <?= $type ?>>  *

            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td width="22%" height="25">期望完成时间：</td>
            <td width="78%" height="25"><input name="info[end_time]" type="text"  id="end_time" required="required"  value="<?=$info['end_time']?>" <?= $type ?>>  *
            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td width="22%" height="25">紧急程度：</td>
            <td width="78%" height="25">
                <input name="info[emergency_level]" type="radio"value="1" size="32"    <?php  if($info['emergency_level']==1){   ?> checked="checked" <?php }  ?>> 特急
                <input name="info[emergency_level]" type="radio"value="2" size="32" <?php  if($info['emergency_level']==2){   ?> checked="checked" <?php }  ?>> 紧急
                <input name="info[emergency_level]" type="radio"value="3" size="32" <?php  if($info['emergency_level']==3){    ?> checked="checked" <?php }  ?>> 正常
                <input name="info[emergency_level]" type="radio"value="4" size="32" <?php  if($info['emergency_level']==4){    ?> checked="checked" <?php }  ?>> 可延期
            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td width="22%" height="25">变更类型：</td>
            <td width="78%" height="25">
                <input name="info[change_type]" type="radio"value="1" size="32" <?php  if($info['change_type']==1){    ?> checked="checked" <?php }  ?>> 新增
                <input name="info[change_type]" type="radio"value="2" size="32" <?php  if($info['change_type']==2){    ?> checked="checked" <?php }  ?>> 优化
                <input name="info[change_type]" type="radio"value="3" size="32" <?php  if($info['change_type']==3){    ?> checked="checked" <?php }  ?>> 体验
                <input name="info[change_type]" type="radio"value="4" size="32" <?php  if($info['change_type']==4){    ?> checked="checked" <?php }  ?>> bug修改
            </td>
        </tr>

        <tr bgcolor="#FFFFFF">
            <td width="22%" height="25">变更原因：</td>
            <td width="78%" height="25"><textarea name="info[change_reason]" type="text"  id="change_reason" required="required"  <?= $type ?>
                                                  value="" size="32"><?=$info['change_reason']?></textarea>*
            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td width="22%" height="25">需求描述：</td>
            <td width="78%" height="25"><textarea name="info[requirement_desc]" type="text"  id="requirement_desc" required="required"  <?= $type ?>
                                                  value="" size="32"><?=$info['requirement_desc']?></textarea>*
            </td>
        </tr>
    </table>
</form>
<?php   if($_GET['type']!=='see'){?>
<tr bgcolor="#FFFFFF">
    <td height="25">&nbsp;</td>
    <td height="25"><button  onclick="Requestsubmit();">提交</button> <input type="reset" name="Submit2"
                                                                           value="重置"></td>
</tr>
<?php  } ?>

<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
    <tr class="header">
        <td width="10%" height="25"><div align="center">审核人</div></td>
        <td width="15%" height="25"><div align="center">审核时间</div></td>
        <td width="15%" height="25"><div align="center">审核状态</div></td>
        <td width="30%" height="25"><div align="center">备注</div></td>
    </tr>
    <?php foreach($listArr as $list){  ?>
        <tr bgcolor="ffffff" onmouseout="this.style.backgroundColor='#ffffff'" onmouseover="this.style.backgroundColor='#C3EFFF'">
            <td width="10%" height="25"><div align="center"><?=$list['username']?></div></td>
            <td width="15%" height="25"><div align="center"><?=$list['add_time']?></div></td>
            <?php if($userid!==$list['userid']){ ?>
                <td width="20%" height="25"><div align="center"><?php echo str_replace([1,2,],['<b style="color: green">同意</b>','<b style="color: red">拒绝</b>'],$list['record']['status'])?></div></td>

            <?php  }else if($list['record']['status']){ ?>
                <td width="20%" height="25"><div align="center"><?php echo str_replace([1,2,],['<b style="color: green">同意</b>','<b style="color: red">拒绝</b>'],$list['record']['status'])?></div></td>
            <?php }else{ ?>
            <td width="20%" height="25"><div align="center"><button style="background: green" onclick="if(confirm('确认同意吗')){changeStatus(this,<?=$userid?>,<?=$list['groupid']?>,1)}">同意</button><button style="background: red" onclick="if(confirm('确认拒绝吗')){changeStatus(this,<?=$userid?>,<?=$list['groupid']?>,2)}">拒绝</button></div></td>
            <?php  } ?>
            <td width="15%" height="25"><div align="center"><textarea class="remark"  ><?=$list['record']['remark']?></textarea></div></td>
        </tr>
    <?php  } ?>
</table>
</body>
<script>
    $(function () {
        <?php   if($_GET['type']!=='see'){?>
        $( "#start_time" ).datepicker({dateFormat: "yy-mm-dd"});
        $( "#end_time" ).datepicker({dateFormat: "yy-mm-dd"});
        <?php  } ?>
    })
    //提交表单
    function Requestsubmit() {
        //验证

        var data=$("#requestfom").serialize();
        $.ajax({
            url:"requirement.php?method=edit",    //请求的url地址
            dataType:"json",   //返回格式为json
            async:true,//请求是否异步，默认为异步，这也是ajax重要特性
            data:data,    //参数值
            type:"POST",
            success:function(result){
                if(result.code==200){
                    //成功
                    alert(result.msg);
                    window.location.href='requirement.php?status=<?=$status?>&method=list'
                }else{
                    alert(result.msg);
                }
            },
        });
    }
    //审核
    function changeStatus(e,userid,groupid,status) {
        var remark=$(e).parent('div').parent().parent().find('.remark').val();
        $.ajax({
            url:"requirement.php?method=examine",    //请求的url地址
            dataType:"json",   //返回格式为json
            async:true,//请求是否异步，默认为异步，这也是ajax重要特性
            data:{userid:userid,groupid:groupid,status:status,remark:remark,requirement_id:<?=$id?>},    //参数值
            type:"POST",
            success:function(result){
                if(result.code==200){
                    //成功
                    alert(result.msg);
                    window.location.reload()
                }else{
                    alert(result.msg);
                }
            },
        });
    }
</script>
</html>
